//广告招租
import React, { Component } from 'react';
import {
    View,
    Image,
    Dimensions,
    StatusBar,
    TouchableOpacity
} from 'react-native';
import { NavigationActions } from 'react-navigation';
import NumberUtil from '../../utils/NumberUtil';
import Timer from '../../utils/Timer'


let splashImgs = [
    require('./../../assets/img/ic_splash_1.jpg'),
    require('./../../assets/img/ic_splash_2.jpg'),
    require('./../../assets/img/ic_splash_3.jpg'),
    require('./../../assets/img/ic_splash_4.jpg')
];


export default class Splash extends Component {


    goPass() {
        var resetAction = NavigationActions.reset({
            index: 0,
            actions: [
                NavigationActions.navigate({ routeName: 'App' }),//要跳转到的页面名字
        
            ]
        });
        var navigation = this.props.navigation;
        return function () {
            navigation.dispatch(resetAction);
            NavigationActions.navigate({ routeName: 'App' })//要跳转到的页面名字
        }
    }

    render() {
        let { width, height } = Dimensions.get("window");
        let randomNum = NumberUtil.getRandom(0, splashImgs.length - 1);
        return (
            <View style={{ flex: 1 }}>
                <StatusBar hidden={true} />
                <Image source={splashImgs[randomNum]} resizeMode={'cover'} style={{ width: width, height: height }} />
                <View style={{ flex: 1, position: "absolute", right: 20, bottom: 20 }}>
                    <TouchableOpacity activeOpacity={1}>
                        <Timer t={2} text={"点击跳过"} rollBack={this.goPass()} />
                    </TouchableOpacity>
                </View>
            </View>
        )
    }
}
